import React from 'react';
import { useRequest, defaultFormatResult } from '@/hooks';
import { getPostApplyData } from '@/pages/WorkFlow/services';
import { launchApprovalProcess } from '@/pages/Recruitment/Hire/Communicate/containers/Action';

// 重新发起审批
export default function useRelaunch(hiDataId) {
    const { loading, run } = useRequest(() => getPostApplyData(hiDataId), {
        manual: true,
        ...defaultFormatResult
    });
    const handleJump = React.useCallback(async () => {
        if (!hiDataId) return;
        const params = await run();
        await launchApprovalProcess({ params });
    }, []);
    return [loading, handleJump];
}
